package Test;

import java.util.ArrayList;
import java.util.List;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import service.GoodsService;
import service.LoginService;
import vo.Commodity;
import vo.Store;


public class GoodsTest {
	@Autowired(required=true)
	private static  GoodsService gs;
	private static LoginService ls;
	
	@BeforeClass
	public static void beforeClass(){
		ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
		gs=(GoodsService) context.getBean("gs");
		ls=(LoginService) context.getBean("ls");
	}
	//商品上架
/*	@Test
	public void insertGoods(){
		Store s=new Store();
		s=ls.login("3", "er");
		
		Commodity goods=new Commodity();
		goods.setCommodityCode("3");
		goods.setCommodityName("ze");
		goods.setCommodityPrice("3343");
		goods.setStore(s);
		gs.insertGoods(goods);
		
	}*/
	
/*	//修改商品
	@Test
	public void updateGoods(){
		Store s=new Store();
		s=ls.login("3", "er");
		System.out.println(s.getEmail());
		Commodity goods=new Commodity();
		goods=gs.queryGoods(3);
		System.out.println(goods.getCommodityId());
		goods.setCommodiryNum(1);
		goods.setCommodityCode("1");
		goods.setCommodityName("323");
		goods.setCommodityPrice("43");
	//	goods.setStore(s);
		System.out.println(goods.getStore().getEmail());
		gs.updateGoods(goods);
		
	}*/
/*	@Test
	public void deleteGoods(){
		gs.deleteGoods(3);
	}*/
	
	@Test
	public void queryAllGoods(){
		List<Commodity> commodities=new ArrayList<Commodity>();
		Store store=new Store();
		store.setId(1);
		commodities=gs.queryAllGoods(store);
		for(int i=0;i<commodities.size();i++){
			System.out.println(commodities.get(i).getCommodiryNum());
		}
	}
	
	
	
	
	
	
	
}
